﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Administrador.Publicidad
{
    public partial class Fondos : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void btnSubirContenido_Click(object sender, EventArgs e)
        {
            Boolean fileOK = false;
            String path = Server.MapPath("../Fondos/");
            if (fuContenido.HasFile)
            {
                String fileExtension =
                    System.IO.Path.GetExtension(fuContenido.FileName).ToLower();
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        fileOK = true;
                    }
                }
            }

            if (fileOK)
            {
                try
                {
                    fuContenido.PostedFile.SaveAs(path
                        + fuContenido.FileName);
                    lblError.Text = "File uploaded!";
                }
                catch (Exception ex)
                {
                    lblError.Text = "File could not be uploaded.";
                }
            }
            else
            {
                lblError.Text = "Cannot accept files of this type.";
            }
               
        }

    }
}